import random
money=5000
number=random.randint(1,100)
while True:
    guess_input=input("请猜数字：")
    try:
        guess_number=int(guess_input)
        if number>guess_number:
            print("小了")
            money-=500
        elif number<guess_number:
            print("大了")
            money-=500
        elif number==guess_number:
            money+=5000
            print("恭喜猜中，本轮幸运数字：",number)
            print("金币剩余:", money)
            print("是否继续下一轮游戏?请回答“是”或”否“")
            answer=input()
            while answer!="是" and answer!="否":
                print("输入错误，请输入“是”或”否“:")
                answer=input()
            if answer == "是":
                print("继续游戏")
            elif answer == "否":
                print("退出游戏")
                break
            number=random.randint(1,100)
        if money<500:
            print("金币不足，只有:",money,"了！")
            break
    except ValueError:
        print("您输入错误，请输入数字！")